<template>
    <div class="contentpieceright">
        <!-- 个人信息 -->
        <div class="contentpiece">
            <div class="userBox">
                <!-- <el-image :src="userInfo.head" class="userimage" @click="toAssignPage('/user/mymanagement/userinfo')">
                    <template #error>
                        <el-image src="https://cube.elemecdn.com/3/7c/3ea6beec64369c2642b92c6726f1epng.png" @click="toAssignPage('/user/mymanagement/userinfo')" class="userimage"> </el-image>
                    </template>
                </el-image> -->
                <images v-if="userInfo.pic" :src="userInfo.pic" class="userimage" imgType="1" @click="toAssignPage('/user/mymanagement/userinfo')" />
                <el-image class="userimage" v-else :src="require('@/assets/image/userinfoimg.png')" @click="toAssignPage('/user/mymanagement/userinfo')" fit="cover"></el-image>
                <div class="usermsgboxright">
                    <div class="usermsgbox">
                        <div>
                            <div class="welcome">你好！</div>
                            <div class="username">{{ userInfo.nickName }}</div>
                        </div>
                        <el-button link type="primary" class="titleBtns" @click="router.push('/user/mymanagement/userinfo')" size="default">前往个人中心</el-button>
                    </div>
                    <div class="usermsgitem">
                        <div class="usermsgitemName">主团队：</div>
                        <div class="usermsgitemcontent">{{ mainTeam ? mainTeam.teamName : "未设置主团队" }}</div>
                    </div>
                    <div class="usermsgitem">
                        <div class="usermsgitemName">职 位：</div>
                        <div class="usermsgitemcontent">{{ mainTeam ? mainTeam.positionName : "未设置主团队" }}</div>
                    </div>
                    <div class="usermsgitem">
                        <div class="usermsgitemName">应用行业：</div>
                        <div class="usermsgitemcontent">{{ mainTeam ? industry(mainTeam.industrialClassificationList) : "未设置主团队" }}</div>
                    </div>
                    <div class="usermsgitem">
                        <div class="usermsgitemName">联系地址：</div>
                        <div class="usermsgitemcontent" :title="formattingAddress()">{{ formattingAddress() ? formattingAddress() : "未设置联系地址" }}</div>
                    </div>
                    <div class="attestationmsg">
                        <el-button link class="titleBtns attestationy" :class="userInfo.certified == 2 ? 'attestationyfinish' : ''" @click="toAssignPage('/user/mymanagement/certificateauth')">
                            {{ userInfo.certified <= 0 ? "前往个人认证" : userInfo.certified == 1 ? "个人认证中" : "已完成认证" }}
                        </el-button>
                        <!-- <el-button link type="primary" class="titleBtns attestationy" size="default">已绑定支付</el-button> -->
                    </div>
                </div>
            </div>
        </div>
        <div v-show="navListType == 1">
            <!-- 费用概览 -->
            <div class="contentpiece">
                <div class="rightTitle">
                    <div class="contentpieceTitle">费用概览</div>
                    <el-button link type="primary" class="titleBtns" size="default" @click="toAssignPage('/expense/shoppingtrolley')">前往财务中心</el-button>
                </div>
                <div class="balance">
                    <div class="name">可用余额</div>
                    <div class="money">￥0.00</div>
                    <div class="btns">
                        <div class="btn">充值</div>
                        <div class="btn">提现</div>
                    </div>
                </div>
                <div class="resourcebox">
                    <div class="resourceitem">
                        <div class="resourcemsg">可开发票金额 ￥230.00</div>
                        <div class="resourcenum"><el-button link type="primary" class="titleBtns" size="default">去开票</el-button></div>
                    </div>
                    <div class="resourceitem">
                        <div class="resourcemsg">代金券 0张（￥0.00）</div>
                        <div class="resourcenum">
                            <el-icon><ArrowRight /></el-icon>
                        </div>
                    </div>
                </div>
            </div>
            <!-- 成本概览 -->
            <div class="contentpiece">
                <div class="rightTitle">
                    <div class="contentpieceTitle">成本概览</div>
                    <el-button link type="primary" class="titleBtns" size="default" @click="toAssignPage('/expense/shoppingtrolley')">前往成本中心</el-button>
                </div>
                <div class="ttop">
                    成本概况
                    <el-icon class="icons"><Warning /></el-icon>
                </div>
                <div class="costlist" v-for="item in 2" :key="item">
                    <div class="time">
                        当月成本（2024-07-01——2024-07-30 GMT+08：00）
                        <el-icon class="icons"><Warning /></el-icon>
                    </div>
                    <div class="money">￥960.00</div>
                    <div class="data">上周周期：￥320.00，环比上月：+200.00%</div>
                </div>
                <div class="costlistTip">以上成本均为原始成本，等同于账单中的应付金额，什么是原始成本？</div>
            </div>
        </div>
        <div v-show="navListType == 2 || navListType == 3">
            <!-- 优秀解决方案推荐 -->
            <div class="contentpiece">
                <div class="rightTitle">
                    <div class="contentpieceTitle">优秀解决方案推荐</div>
                    <el-button link type="primary" class="titleBtns" size="default">更多</el-button>
                </div>
                <div class="schemeBox">
                    <div class="schemeItem" v-for="item in 5" :key="item">
                        <el-image class="schemeItemImg" src="https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg" fit="cover"></el-image>
                        <div class="schemeItemRight">
                            <div class="schemeItemName">一体化监控解决方案</div>
                            <div class="schemeItemTip">帮助果园实现全园监控，实现对果园防 盗、果树生长情况等系统解决方案</div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <!-- 通知公告 -->
        <div class="contentpiece">
            <div class="rightTitle">
                <div class="contentpieceTitle">通知公告</div>
                <el-button link type="primary" class="titleBtns" size="default" @click="router.push('/inform/information/fullmessage')">更多通知</el-button>
            </div>
            <div class="announcementBox">
                <div class="announcementItem" v-for="item in 5" :key="item"><span>2024-07-25</span>【管理公告】三峡农夫公司关于XX的公告【管理公告】三峡农夫公司关于XX的公告</div>
            </div>
        </div>
        <!-- 品牌管理 -->
        <div class="contentpiece">
            <div class="rightTitle">
                <div class="contentpieceTitle">品牌管理</div>
                <el-button link type="primary" class="titleBtns" size="default" @click="router.push('/inform/information/fullmessage')">品牌管理</el-button>
            </div>
            <div class="announcementBox">
                <div class="announcementItem" v-for="item in 5" :key="item">【管理公告】三峡农夫公司关于XX的公告【管理公告】三峡农夫公司关于XX的公告</div>
                <el-button link type="primary" class="titleBtns" size="default" @click="router.push('/inform/information/fullmessage')">
                    更多
                    <el-icon><ArrowRight /></el-icon>
                </el-button>
            </div>
        </div>
        <!-- 品牌管理 -->
        <div class="contentpiece">
            <div class="rightTitle">
                <div class="contentpieceTitle">品牌管理</div>
            </div>
            <div class="code">
                <div class="item">
                    <img src="https://web-ext-storage.dcloud.net.cn/uni-app-x/hello-uniappx-qrcode.png" class="codeimg" alt="" srcset="" />
                    <div class="name">
                        <img src="@/assets/images/index/20.png" class="icon" alt="" srcset="" />
                        苹果
                    </div>
                </div>
                <div class="item">
                    <img src="https://web-ext-storage.dcloud.net.cn/uni-app-x/hello-uniappx-qrcode.png" class="codeimg" alt="" srcset="" />
                    <div class="name">
                        <img src="@/assets/images/index/21.png" class="icon" alt="" srcset="" />
                        安卓
                    </div>
                </div>
                <div class="item">
                    <img src="https://web-ext-storage.dcloud.net.cn/uni-app-x/hello-uniappx-qrcode.png" class="codeimg" alt="" srcset="" />
                    <div class="name">
                        <!-- <img src="https://web-ext-storage.dcloud.net.cn/uni-app-x/hello-uniappx-qrcode.png" class="icon" alt="" srcset="" /> -->
                        鸿蒙
                    </div>
                </div>
            </div>
        </div>
    </div>
</template>
<script lang="ts" setup>
import { computed, nextTick } from "vue";
import { useStore } from "vuex";
import { useRouter } from "vue-router";

import { getUserInfo } from "@/api/user";
const store = useStore();
const router = useRouter();
console.log(store);
interface Props {
    navListType: number;
}
const props = withDefaults(defineProps<Props>(), {
    // 高度默认20
    navListType: 1,
});
const userInfo: any = computed((e: any) => {
    return store.getters.userInfo;
});
getUserInfo().then((res: any) => {
    store.commit("setUserInfo", res.data);
    userInfo.value = res.data;
});
console.log(userInfo);
const mainTeam: any = computed((e: any) => {
    let list = store.getters.teamList;
    let team = "";
    list.forEach((v: any) => {
        if (v.isMainTeam) {
            team = v;
        }
    });
    return team;
});
const industry = (data: []) => {
    let list: Array<[string]> = [];
    data.forEach((v: any) => {
        list.push(v.industrialName);
    });
    return list.join("/");
};
const formattingAddress = () => {
    let info = userInfo.value;
    if (info.addressArea) {
        let addr = "";
        if (info.address) {
            addr = `${JSON.parse(info.addressArea).valueText}/${info.address}`;
        } else {
            addr = `${JSON.parse(info.addressArea).valueText}`;
        }
        return addr;
    } else {
        return "";
    }
};
// const
const toAssignPage = (url: string, tag?: string, title?: string) => {
    // this.$store.commit('setMenuIdentification', {
    //     tag,
    //     title
    // })
    // this.$fn.setSelectMenu(url, tag)
    // window.open(url);
    router.push(url);
};
</script>
<style lang="scss" scoped>
.contentpieceright {
    width: 385px;
    margin-left: 20px;
    .userBox {
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        .userimage {
            width: 40px;
            height: 40px;
            margin-right: 10px;
            border-radius: 100%;
            cursor: pointer;
            overflow: hidden;
        }
        .usermsgboxright {
            width: 285px;
            .usermsgbox {
                display: flex;
                justify-content: space-between;
                align-items: center;
                margin-bottom: 20px;
                .welcome {
                    font-size: 12px;
                    color: #252b3a;
                    margin-bottom: 5px;
                }
                .username {
                    font-size: 12px;
                    color: #23b14d;
                }
                .titleBtns {
                    font-size: 12px;
                }
            }
            .usermsgitem {
                display: flex;
                justify-content: flex-start;
                align-items: center;
                margin-bottom: 10px;
                .usermsgitemName {
                    width: 60px;
                    font-size: 12px;
                    color: #666666;
                    text-align: left;
                    white-space: nowrap;
                }
                .usermsgitemcontent {
                    font-size: 12px;
                    color: #666666;
                    overflow: hidden;
                    text-overflow: ellipsis;
                    white-space: nowrap;
                    width: 280px;
                }
            }
            .attestationmsg {
                margin-top: 20px;
                .attestationy {
                    position: relative;
                    margin-left: 30px;
                    font-size: 12px;
                    &:first-child {
                        margin-left: 15px;
                    }
                    &::before {
                        content: "";
                        position: absolute;
                        width: 8px;
                        height: 8px;
                        border: 1px solid #23b14d;
                        left: -15px;
                        border-radius: 100%;
                    }
                }
                .attestationyfinish {
                    color: #23b14d;
                    &::after {
                        background: #23b14d;
                        content: "";
                        position: absolute;
                        width: 4px;
                        height: 4px;
                        border-radius: 100%;
                        left: -12px;
                        top: 50%;
                        transform: translateY(-50%);
                    }
                }
            }
        }
    }
    .resourcebox {
        margin-top: 20px;
        .resourceitem {
            margin-top: 10px;
            padding: 10px 0;
            display: flex;
            justify-content: space-between;
            align-items: center;
            border-bottom: 1px dashed rgba(0, 0, 0, 0.05);

            .resourcemsg {
                font-size: 12px;
                color: #333333;
            }
            .resourcenum {
                font-size: 12px;
                color: #333333;
                .titleBtns {
                    font-size: 12px;
                }
            }
        }
    }
    .announcementBox {
        margin-top: 10px;
        .announcementItem {
            margin-top: 20px;
            font-size: 12px;
            color: #252b3a;
            span {
                margin-right: 20px;
            }
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }
        .titleBtns {
            font-size: 12px;
            margin-top: 20px;
        }
    }
    .schemeItem {
        height: 70px;
        cursor: pointer;
        margin-top: 20px;
        display: flex;
        justify-content: flex-start;
        align-items: center;
        &:hover {
            box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
        }
        .schemeItemImg {
            height: 100%;
            width: 120px;
            margin-right: 20px;
        }
        .schemeItemRight {
            width: 255px;
            .schemeItemName {
                font-size: 14px;
                font-weight: bold;
                color: #252b3a;
            }
            .schemeItemTip {
                font-size: 12px;
                color: #666666;
                line-height: 18px;
            }
        }
    }
    .rightTitle {
        display: flex;
        justify-content: space-between;
        align-items: center;
        .titleBtns {
            font-size: 12px;
        }
    }
    .contentpiece {
        background: #ffffff;
        box-shadow: 0px 2px 5px 0px rgba(0, 0, 0, 0.03);
        padding: 20px;
        margin-bottom: 15px;
        position: relative;
        .balance {
            margin-top: 20px;
            width: 100%;
            height: 130px;
            background: rgba(51, 51, 51, 0.05);
            padding: 20px;
            .name {
                font-size: 12px;
                color: #999999;
            }
            .money {
                font-weight: 500;
                font-size: 24px;
                color: #333333;
                margin: 10px 0;
            }
            .btns {
                display: flex;
                justify-content: flex-start;
                align-items: center;
                .btn {
                    width: 52px;
                    height: 20px;
                    border: 1px solid rgba(0, 0, 0, 0.2);
                    line-height: 20px;
                    text-align: center;
                    cursor: pointer;
                    margin-right: 10px;
                    font-size: 12px;
                    color: #333333;
                    &:first-child {
                        background: #23b14d;
                        color: #ffffff;
                        border: 1px solid #23b14d;
                    }
                }
            }
        }
        .ttop {
            margin-top: 20px;
            font-size: 12px;
            color: #000000;
            .icons {
                font-size: 12px;
                color: #a9a9a9;
                margin-left: 5px;
            }
        }
        .costlist {
            margin-top: 16px;
            padding-bottom: 10px;
            border-bottom: 1px double rgba(0, 0, 0, 0.1);
            margin-bottom: 10px;
            .time {
                font-size: 10px;
                color: #666666;
                .icons {
                    font-size: 10px;
                    color: #a9a9a9;
                    margin-left: 5px;
                }
            }
            .money {
                font-size: 16px;
                color: #000000;
                margin: 10px 0;
            }
            .data {
                font-size: 10px;
                color: #666666;
            }
        }
        .costlistTip {
            font-size: 10px;
            color: #666666;
        }
        .code {
            display: flex;
            justify-content: space-between;
            align-items: flex-start;
            margin-top: 20px;
            .item {
                width: 33.33%;
                .codeimg {
                    width: 100%;
                }
                .name {
                    display: flex;
                    justify-content: center;
                    align-items: center;
                    font-size: 12px;
                    color: #000000;
                    margin-top: 5px;
                    .icon {
                        width: 10px;
                        height: 10px;
                        margin-right: 5px;
                    }
                }
            }
        }
    }
    .contentpieceTitle {
        font-size: 14px;
        font-weight: bold;
        color: #252b3a;
        margin-right: 10px;
    }
}
</style>
